/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package MODEL.DAO;
import MODEL.POJO.*;
import java.util.*;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;


/**
 *
 * @author samph
 */
public class AdministratorsDao {
    public static  List<Administrators> KiemTraDangNhapAdmin(String username, String pass){
        List<Administrators> ds = null; 
        //Session session = HibernateUtil.getSessionFactory().openSession();
        Session session = (Session) HibernateUtil.getSessionFactory().openSession();
        int count = 0;
        try { 
            String hql = "from Administrators a where a.administratorUsername = :username and a.administratorPassword = :pass"; 
            Query query = session.createQuery(hql); 
            query.setParameter("username", username);
            query.setParameter("pass",pass);
            ds = query.list(); 
            count = ds.size();
        } catch (HibernateException ex) { 
            System.err.println(ex); 
        } finally { 
           //session.close(); 
        } 
        return ds; 
    }
}